package chapter04.d3_junit;

import chapter04.d3_junit.Calculator;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class CalculatorTest {
    private Calculator calculator;
    @Before
    public void init(){
        System.out.println("程序最先执行-资源初始化");
        calculator=new Calculator();
    }

    @After
    public void destroy(){
        System.out.println("程序最后执行-资源释放");
    }

    @Test
    public void testAdd(){
        int result=calculator.add(1,2);
        System.out.println(result);
        Assert.assertEquals(3,result);
    }

    @Test
    public void testSub(){
        int result=calculator.sub(1,2);
        System.out.println(result);
    }
}
